//
//  GTLoggerHostApiImpl.swift
//  lib_core
//
//  Created by Shper on 2024/2/20.
//

import Foundation
import RangersAPM

class GTLoggerHostApiImpl: GTLoggerHostApi {
    
    func logRecovery(level: String, tag: String, message: String, fileName: String, funcName: String, line: Int64) throws {
        
        // 避免强转换溢出
        var lineInt32: Int32 = 0
        if let int32Value = Int32(exactly: line) {
            lineInt32 = int32Value
        }
        
        switch level.lowercased() {
            case "verbose", "debug":
                RangersAPM.debugALog(message, tag: tag, fileName: fileName, funcName: funcName, line: lineInt32)
            case "info":
                RangersAPM.infoALog(message, tag: tag, fileName: fileName, funcName: funcName, line: lineInt32)
            case "warning":
                RangersAPM.warnALog(message, tag: tag, fileName: fileName, funcName: funcName, line: lineInt32)
            case "error":
                RangersAPM.errorALog(message, tag: tag, fileName: fileName, funcName: funcName, line: lineInt32)
            default: break
                // Ignore
            }
    }
    
}
